/**
 * Created by yangfan on 2016/10/12.
 */
define(['config/appregister',
    "i18n",
    "business/personMine/services/httpServices",
    "business/services/personCenterComp",
    "business/services/detailNavComp",
    "business/services/filter"],function(app,i18n,httpServices){
    app.controller('personOtherCtrl', function($scope,$state,$rootScope) {
        $scope.i18n = i18n;
        $scope.leftNav = [
            {title:"Ta的上传",state:"personOther.upload"},
            {title:"Ta的课程",state:"personOther.videos"},
            {title:"Ta的问答",state:"personOther.questions"},
            {title:"Ta的好友",state:"personOther.friends",type:'care'},
        ];


        $scope.$on('getOthersId',function(a,b){
             getBasePersonInfoByOther(b.userId);
             $scope.otherUserId = b.userId ;
        });


        function getBasePersonInfoByOther(userId){
            var req = {
                type:"GET",
                uri:"getBasePersonInfoByOther",
                data:{
                    otherUserId:userId
                }
            };
            httpServices.personServices(req).success(function(response){
                $scope.$apply(function(){
                    $scope.userPic = response.data.logo ;
                })
            }).error(function(){})
        }

        $scope.currentItem = [];
        $scope.changeView = function(item){
            if(typeof item.state=="string" &&item.state!=""){
                if(!angular.isUndefined(item.type)){
                    $state.go(item.state,{type:item.type,userId:$scope.otherUserId});
                }else{
                    $state.go(item.state,{userId:$scope.otherUserId});
                }
            }
        };
        $scope.jumpToState = function(state){
            if(!state){
                return
            }
            if(state == 'myMainPage'){
                $state.go(state,{userId:$rootScope.userLoginInfo.data.userId});
            }else{
                $state.go(state);
            }
        };
        $scope.jumpToBlog = function(item){
            $state.go(item,{'userId':$scope.otherUserId})
        }
        $scope.goOthersMainPage = function(){
            $state.go('othersMainPage',{userId:$scope.otherUserId})
        }

    })
});